package arrays;

import java.util.Arrays;
import java.util.Scanner;

public class arrays_13 {

    public static void main (String [] args ){
        // 设 names 数组中存放学生姓名
        String[] names = { "雷军" , "马云" , "周鸿祎" , "丁磊" , "李彦宏" };

        // 设 courses 数组中依次存放三门课程的名称
        String[] courses = { "C++" , "Java" , "English" };

        // 设 scores 数组中依次存储的是 names 数组中各个学生的 C++ 、Java 、English 课程的成绩
        int[][] scores = {
                {  90 ,  89 ,  75 } ,
                {  59 ,  40 , 100 } ,
                { 100 ,  99 ,  80 } ,
                {  80 ,  61 ,  61 } ,
                {  60 , 100 ,  99 } ,
        };
        int[] sum = new int[5] ;
        int temp ;
        int [] intArrays;
        String str ;
        for (int i = 0; i < 5; i++) {
            for (int j = 0; j < 3; j++) {
                sum [i] += scores[i][j];
            }

        }
        for (int i = 0; i < 5 - 1  ; i++) {
            for (int j = 0; j < 5 - i - 1; j++) {
                if ( sum [j] <= sum [j+1] ){
                    temp = sum[j];
                    sum[j] = sum[j+1];
                    sum[j+1] = temp ;

                    intArrays = scores[j] ;
                    scores[j] = scores[j+1] ;
                    scores[j+1] = intArrays ;

                    str = names[j];
                    names[j] = names[j+1];
                    names[j+1] = str ;
                }
            }

        }
        for (int i = 0; i < 5; i++) {
            System.out.print( "\t" + "姓名:" + names[i] );
            for (int j = 0; j < 3; j++) {
                System.out.print(  "\t\t" + courses[j] + ":" + "\t" + scores[i][j]);
            }
            System.out.println( "\t\t\t" + "总分：" + sum[i] );
        }

    }
}
